package com.tjvib.view.activity;

import static com.tjvib.Constants.METHOD_CENSUS;
import static com.tjvib.Constants.METHOD_DAMPING;
import static com.tjvib.Constants.METHOD_FFT;
import static com.tjvib.Constants.METHOD_FREQ;
import static com.tjvib.Constants.METHOD_HUMAN;
import static com.tjvib.Constants.METHOD_MASS;
import static com.tjvib.Constants.METHOD_VSA;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.tjvib.R;
import com.tjvib.adapter.AnalysisMethodAdapter;
import com.tjvib.base.BaseActivity;
import com.tjvib.bean.AnalysisMethodBean;
import com.tjvib.presenter.BasePresenter;
import com.tjvib.util.LogUtil;

import java.util.ArrayList;
import java.util.List;

public class AnalysisMethodActivity extends BaseActivity {

    private RecyclerView ana_rv;

    private AnalysisMethodAdapter analysisMethodAdapter;
    private List<AnalysisMethodBean> analysisMethodBeanList = new ArrayList<>();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected int initLayout() {
        return R.layout.activity_analysis_method;
    }

    @Override
    protected boolean initView() {
        ana_rv = findViewById(R.id.ana_rv);
        return true;
    }

    @Override
    protected boolean initData() {
        analysisMethodBeanList = new ArrayList<>();
        analysisMethodBeanList.add(new AnalysisMethodBean(R.mipmap.flybh, METHOD_FFT));
        analysisMethodBeanList.add(new AnalysisMethodBean(R.mipmap.gsznb, METHOD_DAMPING));
        analysisMethodBeanList.add(new AnalysisMethodBean(R.mipmap.syzbtj, METHOD_CENSUS));
        analysisMethodBeanList.add(new AnalysisMethodBean(R.mipmap.rgjz, METHOD_HUMAN));
        analysisMethodBeanList.add(new AnalysisMethodBean(R.mipmap.ssdpg, METHOD_VSA));
        analysisMethodBeanList.add(new AnalysisMethodBean(R.mipmap.freq, METHOD_FREQ));
        analysisMethodBeanList.add(new AnalysisMethodBean(R.mipmap.mass, METHOD_MASS));

        ana_rv.setLayoutManager(new GridLayoutManager(this, 3));

        analysisMethodAdapter = new AnalysisMethodAdapter(R.layout.item_analsis_method,
                analysisMethodBeanList, this);
        analysisMethodAdapter.setOnItemClickListener((adapter, view, position) -> {
            Intent intent = new Intent(this, InterceptActivity.class);
            switch (position) {
                case 0:
                    intent.putExtra("METHOD", METHOD_FFT);
                    this.startActivity(intent);
                    break;
                case 1:
                    intent.putExtra("METHOD", METHOD_DAMPING);
                    this.startActivity(intent);
                    break;
                case 2:
                    intent.putExtra("METHOD", METHOD_CENSUS);
                    this.startActivity(intent);
                    break;
                case 3:
                    intent.putExtra("METHOD", METHOD_HUMAN);
                    this.startActivity(intent);
                    break;
                case 4:
                    intent.putExtra("METHOD", METHOD_VSA);
                    this.startActivity(intent);
                    break;
                case 5:
                    intent.putExtra("METHOD", METHOD_FREQ);
                    this.startActivity(intent);
                    break;
                case 6:
                    intent.putExtra("METHOD", METHOD_MASS);
                    this.startActivity(intent);
                    break;
            }
        });
        ana_rv.setAdapter(analysisMethodAdapter);

        return true;
    }

    @Override
    protected BasePresenter genPresenter() {
        return null;
    }
}